import tkinter as tk

class MyWindow():
    def __init__(self,app):
        self.app = app
        self.app.title("Hello tkinter!")

        # canvas 画布
        self.canvas = tk.Canvas(self.app,width=300,height=300)
        self.canvas.pack()

        # 绘制
        # create_line 绘制直线
        # create_line(左上角坐标，右下角坐标，fill="颜色英文")
        self.canvas.create_line(0,0,300,300,fill="red",arrow="first",width=3)

        # create_rectangle 绘制矩形
        # create_rectangle(左上角坐标，右下角坐标，fill="颜色英文")
        self.canvas.create_rectangle(50,50,250,250,fill="blue",width=2)

        # create_text 绘制文本
        self.canvas.create_text(150,150,text="Hello Canvas",font=('黑体',20),fill="white")

        # create_oval 绘制圆
        self.canvas.create_oval(100,10,200,110,fill="green")

if __name__ == '__main__':
    app = tk.Tk()
    window = MyWindow(app)
    app.mainloop()